package com.heima.article.service.impl;

import com.heima.article.mapper.ApAuthorMapper;
import com.heima.article.service.ApAuthorService;
import com.heima.common.constants.ArticleConstants;
import com.heima.model.article.pojos.ApAuthor;
import com.heima.model.common.dtos.ResponseResult;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
@Service
public class ApAuthorServiceImpl implements ApAuthorService {
    @Autowired
    private ApAuthorMapper authorMapper;
    @Override
    public ResponseResult addAuthor(String name, Integer userId) {
        ApAuthor apAuthor = new ApAuthor();
        apAuthor.setName(name);
        apAuthor.setUserId(userId);
        apAuthor.setType(ArticleConstants.AUTHOR_TYPE_MEDIA);
        apAuthor.setCreatedTime(LocalDateTime.now());
        authorMapper.insert(apAuthor);
        return ResponseResult.okResult(null);
    }
}
